package com.tbit.main.constant;

import com.tbit.main.pojo.DevicePriority;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author: chen
 * @Description: 功能优先级类型常量
 * @Date: 创建于 11:02 2023/3/3
 */
public class DevicePriorityConstant {
    /**
     * 骑行中
     */
    public static final int DEVICEPRIORITY_QXZ = 1;
    /**
     * 运维占用
     */
    public static final int DEVICEPRIORITY_YWZY = 2;
    /**
     * 超区
     */
    public static final int DEVICEPRIORITY_CQ = 3;
    /**
     * 站外
     */
    public static final int DEVICEPRIORITY_ZW = 4;
    /**
     * 禁停区内
     */
    public static final int DEVICEPRIORITY_JTQ = 5;
    /**
     * 运维故障
     */
    public static final int DEVICEPRIORITY_YWGZ = 6;
    /**
     * 无信号
     */
    public static final int DEVICEPRIORITY_WXH = 7;
    /**
     * 电池异常
     */
    public static final int DEVICEPRIORITY_DCYC = 8;
    /**
     * 低电
     */
    public static final int DEVICEPRIORITY_DD = 9;
    /**
     * 闲置车辆
     */
    public static final int DEVICEPRIORITY_XZCL = 10;
    /**
     * 电池未锁
     */
    public static final int DEVICEPRIORITY_DCWS = 11;
    /**
     * 摄像异常
     */
    public static final int DEVICEPRIORITY_SXYC = 12;
    /**
     * 头盔异常
     */
    public static final int DEVICEPRIORITY_TKYC = 13;
    /**
     * 用户故障
     */
    public static final int DEVICEPRIORITY_YHGZ = 14;
    /**
     * 头盔丢失
     */
    public static final int DEVICEPRIORITY_TKDS = 15;
    /**
     * 无盈利
     */
    public static final int DEVICEPRIORITY_WYL = 16;

    /**
     * 载人设备异常
     */
    public static final int DEVICEPRIORITY_ZRSBYC = 17;

    /**
     * 载人设备丢失
     */
    public static final int DEVICEPRIORITY_ZRSBDS = 18;

    /**
     * 扣押状态
     */
    public static final int DEVICEPRIORITY_KYZT = 19;

    /**
     * 入库中
     */
    public static final int DEVICEPRIORITY_RKZ = 20;

    public static List<Integer> getAbnormal(List<Integer> type) {
        List<Integer> list = new ArrayList<>();
        list.add(DEVICEPRIORITY_CQ);
        list.add(DEVICEPRIORITY_ZW);
        list.add(DEVICEPRIORITY_JTQ);
        list.add(DEVICEPRIORITY_WXH);
        list.add(DEVICEPRIORITY_DCYC);
        list.add(DEVICEPRIORITY_DCWS);
        list.add(DEVICEPRIORITY_SXYC);
        list.add(DEVICEPRIORITY_TKYC);
        list.add(DEVICEPRIORITY_TKDS);
        list.add(DEVICEPRIORITY_ZRSBYC);
        list.add(DEVICEPRIORITY_ZRSBDS);
        list.add(DEVICEPRIORITY_KYZT);
        list.add(DEVICEPRIORITY_RKZ);
        list = list.stream().filter(a -> type.contains(a)).collect(
                Collectors.toList());

        List<Integer> integers = new LinkedList<>();
        for (Integer key : list) {
            integers.add(abnormalType(key));
        }
        return integers;
    }

    public static Integer abnormalType(Integer abnormalType) {
        if (abnormalType.equals(DevicePriorityConstant.DEVICEPRIORITY_CQ)) {
            return MachineAbnormalConstant.MACHINE_ABNORMAL_CCQY;
        } else if (abnormalType.equals(DevicePriorityConstant.DEVICEPRIORITY_ZW)) {
            return MachineAbnormalConstant.MACHINE_ABNORMAL_ZW;
        } else if (abnormalType.equals(DevicePriorityConstant.DEVICEPRIORITY_WXH)) {
            return MachineAbnormalConstant.MACHINE_ABNORMAL_WXH;
        } else if (abnormalType.equals(DevicePriorityConstant.DEVICEPRIORITY_DCYC)) {
            return MachineAbnormalConstant.MACHINE_ABNORMAL_DCYC;
        } else if (abnormalType.equals(DevicePriorityConstant.DEVICEPRIORITY_JTQ)) {
            return MachineAbnormalConstant.MACHINE_ABNORMAL_JTYC;
        } else if (abnormalType.equals(DevicePriorityConstant.DEVICEPRIORITY_DCWS)) {
            return MachineAbnormalConstant.MACHINE_ABNORMAL_DCS;
        } else if (abnormalType.equals(DevicePriorityConstant.DEVICEPRIORITY_SXYC)) {
            return MachineAbnormalConstant.MACHINE_ABNORMAL_SXT;
        } else if (abnormalType.equals(DevicePriorityConstant.DEVICEPRIORITY_TKYC)) {
            return MachineAbnormalConstant.MACHINE_ABNORMAL__HELMET;
        } else if (abnormalType.equals(DevicePriorityConstant.DEVICEPRIORITY_TKDS)) {
            return MachineAbnormalConstant.MACHINE_ABNORMAL__HELMET_LOSE;
        } else if (abnormalType.equals(DevicePriorityConstant.DEVICEPRIORITY_ZRSBYC)) {
            return MachineAbnormalConstant.MACHINE_ABNORMAL_MANNED;
        } else if (abnormalType.equals(DevicePriorityConstant.DEVICEPRIORITY_ZRSBDS)) {
            return MachineAbnormalConstant.MACHINE_ABNORMAL_MANNED_LOSE;
        } else if (abnormalType.equals(DevicePriorityConstant.DEVICEPRIORITY_KYZT)) {
            return MachineAbnormalConstant.MACHINE_ABNORMAL_IMPOUND;
        } else if (abnormalType.equals(DevicePriorityConstant.DEVICEPRIORITY_RKZ)) {
            return MachineAbnormalConstant.MACHINE_ABNORMAL_STORAGE;
        }
        return null;
    }

    public static List<DevicePriority> getDefaultDevicePriority() {
        List<DevicePriority> list = new ArrayList<>();
        list.add(new DevicePriority(null,null,DEVICEPRIORITY_QXZ,"骑行中",1,
                "车辆使用中",null,null,null));
        list.add(new DevicePriority(null,null,DEVICEPRIORITY_YWZY,"运维占用",1,
                "车辆使用中", null,null,null));
        list.add(new DevicePriority(null,null,DEVICEPRIORITY_CQ,"超区",2,
                "挪车", null,null,null));
        list.add(new DevicePriority(null,null,DEVICEPRIORITY_ZW,"站外",2,
                "挪车", null,null,null));
        list.add(new DevicePriority(null,null,DEVICEPRIORITY_JTQ,"禁停区内",2,
                "挪车", null,null,null));
        list.add(new DevicePriority(null,null,DEVICEPRIORITY_YWGZ,"运维故障",3,
                "不可运营", null,null,null));
        list.add(new DevicePriority(null,null,DEVICEPRIORITY_WXH,"无信号",3,
                "不可运营", null,null,null));
        list.add(new DevicePriority(null,null,DEVICEPRIORITY_DCYC,"电池异常",3,
                "不可运营", null,null,null));
        list.add(new DevicePriority(null,null,DEVICEPRIORITY_DD,"低电",4,
                "换电", null,null,null));
        list.add(new DevicePriority(null,null,DEVICEPRIORITY_XZCL,"闲置车辆",5,
                "调度", null,null,null));
        list.add(new DevicePriority(null,null,DEVICEPRIORITY_DCWS,"电池未锁",6,
                "待检修", null,null,null));
        list.add(new DevicePriority(null,null,DEVICEPRIORITY_SXYC,"摄像异常",6,
                "待检修", null,null,null));
        list.add(new DevicePriority(null,null,DEVICEPRIORITY_TKYC,"头盔异常",6,
                "待检修", null,null,null));
        list.add(new DevicePriority(null,null,DEVICEPRIORITY_YHGZ,"用户故障",6,
                "待检修", null,null,null));
        list.add(new DevicePriority(null,null,DEVICEPRIORITY_TKDS,"头盔丢失",6,
                "待检修", null,null,null));
        list.add(new DevicePriority(null,null,DEVICEPRIORITY_WYL,"无盈利",6,
                "待检修", null,null,null));
        list.add(new DevicePriority(null,null,DEVICEPRIORITY_KYZT,"扣押状态",3,
                "不可运营", null,null,null));
        list.add(new DevicePriority(null,null,DEVICEPRIORITY_RKZ,"入库中",3,
                "不可运营", null,null,null));

        return list;
    }
}
